home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / source / uMissedCalls.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-06-29  |  4.3 KB  |  157 lines

  1. unit uMissedCalls;
  2.  
  3. {
  4. *******************************************************************************
  5. * Descriptions: Missed calls list and count.
  6. * $Source: /cvsroot/fma/fma/uMissedCalls.pas,v $
  7. * $Locker:  $
  8. *
  9. * Todo:
  10. *
  11. * Change Log:
  12. * $Log: uMissedCalls.pas,v $
  13. * Revision 1.7  2004/06/29 12:37:07  z_stoichev
  14. * New message window renamed
  15. *
  16. * Revision 1.6  2004/06/15 13:03:27  z_stoichev
  17. * Missed calls fixes.
  18. *
  19. * Revision 1.5  2004/04/01 15:06:47  z_stoichev
  20. * unknown contact support
  21. *
  22. * Revision 1.4  2004/03/26 18:37:39  z_stoichev
  23. * Build 0.1.0.35 RC5
  24. *
  25. * Revision 1.3  2003/11/28 09:38:07  z_stoichev
  26. * Merged with branch-release-1-1 (Fma 0.10.28c)
  27. *
  28. * Revision 1.2.2.5  2003/11/21 16:05:48  z_stoichev
  29. * Added Add contact option for unknown numbers.
  30. * List view is not cleared when clear list check is on.
  31. * GUI changes.
  32. *
  33. *
  34. *
  35. *******************************************************************************
  36. }
  37.  
  38. interface
  39.  
  40. uses
  41.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  42.   Dialogs, StdCtrls, ExtCtrls, TntStdCtrls, ComCtrls, TntComCtrls, Menus;
  43.  
  44. const
  45.   sUnknownNumber = 'Unknown Number';    // no number, no stored contact
  46.   sUnknownContact = 'Unknown Contact';  // known number, no stored contact
  47.                                         // known number, stored contact - represented as "cotact name [number]"
  48.  
  49. type
  50.   TfrmMissedCalls = class(TForm)
  51.     lblCountCall: TLabel;
  52.     OkButton: TButton;
  53.     MissedCalls: TTntListView;
  54.     PopupMenu1: TPopupMenu;
  55.     VoiceCall1: TMenuItem;
  56.     SendMessage1: TMenuItem;
  57.     CheckBox1: TCheckBox;
  58.     N1: TMenuItem;
  59.     AddContact1: TMenuItem;
  60.     procedure OkButtonClick(Sender: TObject);
  61.     procedure PopupMenu1Popup(Sender: TObject);
  62.     procedure SendMessage1Click(Sender: TObject);
  63.     procedure VoiceCall1Click(Sender: TObject);
  64.     procedure FormShow(Sender: TObject);
  65.     procedure AddContact1Click(Sender: TObject);
  66.   private
  67.     FMissedCalls: integer;
  68.     { Private declarations }
  69.     function GetSelNumber: string;
  70.     procedure Set_MissedCalls(const Value: integer);
  71.   public
  72.     { Public declarations }
  73.   property
  74.     RecentMissedCalls: integer read FMissedCalls write Set_MissedCalls;
  75.   end;
  76.  
  77. var
  78.   frmMissedCalls: TfrmMissedCalls;
  79.  
  80. implementation
  81.  
  82. {$R *.dfm}
  83.  
  84. uses
  85.   Unit1, uCalling, uComposeSMS, uInfoView;
  86.  
  87. procedure TfrmMissedCalls.OkButtonClick(Sender: TObject);
  88. begin
  89.   if CheckBox1.Checked then RecentMissedCalls := 0;
  90.   Close;
  91.   { Workaround for current calls implementation }
  92.   if Form1.frmInfoView.Visible then Form1.frmInfoView.UpdateWelcomePage(True)
  93.     else Form1.ExplorerChange(nil,Form1.Explorer.Selected);
  94. end;
  95.  
  96. function TfrmMissedCalls.GetSelNumber: string;
  97. var
  98.   s: string;
  99.   i: integer;
  100. begin
  101.   Result := '';
  102.   if (MissedCalls.Selected <> nil) and (MissedCalls.Selected.Caption <> sUnknownNumber) then begin
  103.     s := MissedCalls.Selected.Caption;
  104.     i := Pos('[',s);
  105.     if i <> 0 then begin
  106.       Delete(s,1,i);
  107.       Delete(s,Length(s),1);
  108.     end;
  109.     Result := s;
  110.   end;
  111. end;
  112.  
  113. procedure TfrmMissedCalls.PopupMenu1Popup(Sender: TObject);
  114. begin
  115.   VoiceCall1.Enabled := (MissedCalls.Selected <> nil) and (GetSelNumber <> '');
  116.   SendMessage1.Enabled := VoiceCall1.Enabled;
  117.   AddContact1.Enabled := VoiceCall1.Enabled and (Pos(sUnknownContact,MissedCalls.Selected.Caption) <> 0);
  118. end;
  119.  
  120. procedure TfrmMissedCalls.SendMessage1Click(Sender: TObject);
  121. begin
  122.   if not frmMessageContact.Visible then
  123.     frmMessageContact.Clear;
  124.   Form1.ActionSMSNewMsg.Execute;
  125.   frmMessageContact.AddRecipient(GetSelNumber);
  126. end;
  127.  
  128. procedure TfrmMissedCalls.VoiceCall1Click(Sender: TObject);
  129. begin
  130.   Form1.VoiceCall(GetSelNumber);
  131. end;
  132.  
  133. procedure TfrmMissedCalls.FormShow(Sender: TObject);
  134. begin
  135.   CheckBox1.Checked := False;
  136. end;
  137.  
  138. procedure TfrmMissedCalls.AddContact1Click(Sender: TObject);
  139. begin
  140.   Form1.frmSyncPhonebook.DoEdit(True,GetSelNumber);
  141. end;
  142.  
  143. procedure TfrmMissedCalls.Set_MissedCalls(const Value: integer);
  144. begin
  145.   FMissedCalls := Value;
  146.   if Value <> 0 then begin
  147.     lblCountCall.Caption := 'Recent Missed Calls: ' + IntToStr(Value);
  148.     CheckBox1.Visible := True;
  149.   end
  150.   else begin
  151.     lblCountCall.Caption := 'Missed Calls List:';
  152.     CheckBox1.Visible := False;
  153.   end;
  154. end;
  155.  
  156. end.
  157.